﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
    public partial class ElectricityReading
    {

        Decimal add;

        partial void Balance_Compute(ref decimal result)
        {

          
            IDataServiceQueryable<ElectricityReading> eread = (from o in this.DataWorkspace.databaseData.ElectricityReadings orderby o.Unit.unitNo descending select o).Take(100);
            foreach (ElectricityReading er in eread)
            {
                if (status != "Paid")
                    add = add + this.amount;
            }
            result = add;
            /* IQueryable<ElectricityReading> eread = this.DataWorkspace.databaseData.ElectricityReadings.GroupBy(od => od.amount).Select(g =>
                     new ProductSales()
                     {
                         UnitNo = g.Key.UnitNo,
                         ProductName = g.Key.ProductName,
                         SalesTotalFloat = g.Sum(od =>
                             ((float)(od.UnitPrice * od.Quantity)) * (1 - od.Discount))
                     });
          */
            // if(ElectricityTransactions.status
            //result = this.amounts


        }



    }      
    
}
